package com.niit.TopN.ProvinceTopN;

import com.niit.bean.ProvinceBean;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class ProvinceTopNMapper extends Mapper<LongWritable, Text, ProvinceBean, NullWritable> {
    ProvinceBean outKey = new ProvinceBean();
    NullWritable outValue = NullWritable.get();
    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        String[] fields = value.toString().split(",");
        String school = fields[1];
        String province = fields[7];
        String other = fields[9];
        String ActiveDays = fields[10];
        if ( other == null || other.equals("否") || other.equals("")||
                province == null || province.equals("未知")||province.equals("")) {
            return;
        }
        outKey.set(province,school, Long.parseLong(ActiveDays));
        context.write(outKey,outValue);


    }
}
